//
// Created by Tangruiwen on 15/12/19.
//

#include "types.h"
#include "NativeMethods.h"
#include "ObjectHeap.h"
#include "ClassHeap.h"
#include <iostream>
#include <stdio.h>

Variable Add(JNIEnv* env){
    Frame* pFrameStack = env->pFrameStack;

    Variable returnVal;

    Frame* pFram = &pFrameStack[0];
    returnVal.intValue = pFram->pOpStack[pFram->sp].intValue + pFram->pOpStack[pFram->sp-1].intValue;
    return returnVal;
}

Variable Print(JNIEnv* env){
    Variable returnVal;
    Frame* pFrame = &env->pFrameStack[0];
    Object object = pFrame->stack[pFrame->sp].object;
    Variable* pVal = env->pObjectHeap->GetObjectPointer(object);

    if (pVal){
        char* p = (char*)pVal[1].ptrValue;
        std::string strValue((char*)pVal[1].ptrValue);
        //std::cout<<strValue<<std::endl;
		printf("%s\n", strValue.c_str());
    }
    returnVal.intValue = 0;
	return returnVal;
}

Variable String_valueOf_F(JNIEnv* env){
    Variable returnVal;

    return  returnVal;
}
Variable String_valueOf_J(JNIEnv* env){
    Variable returnVal;

    return  returnVal;
}
Variable StringBuilder_toString_String(JNIEnv* env){
    Variable returnVal;

    return  returnVal;
}